home *** CD-ROM | disk | FTP | other *** search
- /*** NOTE: Tabs are set to 2 in this file ***/
-
- /*
- * {
- * say - a sample program illustrating the use of MacinTalk
- * in a MPW tool. This tool will route standard input
- * through MacinTalk.
- *
- * disclaimer: this program was written hastely and should
- * not be thought of as a very good example
- *
- * parameters:
- * -d debug = on
- * -m mode = robotic
- * -r n rate = n
- * -p n rate = p
- *
- * example usage:
- * Directory | say
- *
- * by Paul Mercer, 3/86
- * modified 7/87 for inclusion in MacinTalk 1.31 release
- * }
- * MPW C version by J. B. Levin 9/88
- */
-
- #include "QuickDraw.h"
- #include "OSutils.h"
- #include "Memory.h"
- #include "Speech.h"
- #include "stdio.h"
- #include "strings.h"
- #include "compat.h" /* Earle Horton's LSC / MPW compatibility macros */
- /* which also gain MPW users easy access to */
- /* the Pascal (or low glue) interface */
-
- Str255 instr;
- SpeechHandle theSpeech; /* handle to speech globals */
- SpeechErr SErr;
- Handle output; /* handle to phonetic string */
- Boolean debug;
- FOMode theMode;
-
- void SayIt ()
- {
- if (debug)
- printf ("Converting text to phonemes.\n");
- SErr = Reader (theSpeech, instr.text, (long)instr.length, output);
- if (debug)
- printf ("Speaking the phonemes\n");
- SErr = MacinTalk (theSpeech, output); /* say it. */
- }
-
- void MyExit ()
- {
- if (debug)
- printf ("Closing MacinTalk.\n");
- SpeechOff (theSpeech); /* close the speech driver. */
- DisposHandle (output); /* release the output handle */
- }
-
- /*** Main program is here. ***/
-
- main (ac, av)
- int ac;
- char *av[];
- {
- int x, y;
-
- if ((SErr = SpeechOn(noExcpsFiles, &theSpeech)) != 0)
- printf ("Error opening MacinTalk: %d\n", SErr);
- theMode = Natural;
- SpeechPitch(theSpeech, 0, theMode);
- debug = false;
-
- for (x = 1; x < ac; x++)
- if (av[x][0] == '-')
- switch (av[x][1])
- {
- case 'D':
- case 'd': { debug = true;
- break;
- }
-
- case 'M':
- case 'm': { if (debug) printf ("Mode is Robotic.\n");
- theMode = Robotic;
- SpeechPitch (theSpeech, 0, theMode);
- break;
- }
-
- case 'R':
- case 'r': { sscanf (av[++x], "%d", &y);
- if (debug) printf ("Rate is %d\n", y);
- SpeechRate (theSpeech, y);
- break;
- }
-
- case 'P':
- case 'p': { sscanf (av[++x], "%d", &y);
- if (debug) printf ("Pitch is %d\n", y);
- SpeechPitch (theSpeech, y, NoChange);
- break;
- }
- } /*end switch, end if, end for*/
-
- /********************* (I didn't try to fiddle this for this demo - /JBL)
- * IF debug THEN
- * WriteLn('now disabling signals.');
- * SErr := IEsighold(SIGALLSIGS); {disable signals}
- ********************/
-
- output = NewHandle (0);
- while (gets (&instr) != NULL)
- {
- c2pstr (&instr);
- SayIt ();
- }
- }
-